﻿using System;
using System.Composition;
using Unread.App.Common;

namespace Unread.App.ViewModels
{
    [Export]
    public class UnreadFeedItemViewModel : BindableBase
    {
        private Guid _feedItemId;
        public Guid FeedItemId 
        {
            get { return _feedItemId; }
            set { SetProperty(ref _feedItemId, value); }
        }

        private string _title;
        public string Title 
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        private string _subtitle;
        public string Subtitle 
        {
            get { return _subtitle; }
            set { SetProperty(ref _subtitle, value); }
        }

        private string _content;
        public string Content
        {
            get { return _content; }
            set { SetProperty(ref _content, value); }
        }

        private Uri _link;
        public Uri Link 
        {
            get { return _link; }
            set { SetProperty(ref _link, value); }
        }

        private Guid _feedId;
        public Guid FeedId 
        {
            get { return _feedId; }
            set { SetProperty(ref _feedId, value); }
        }

        private int _weight;
        public int Weight
        {
            get { return _weight; }
            set { SetProperty(ref _weight, value); }
        }

        private DateTime _publishDate;
        public DateTime PublishDate 
        {
            get { return _publishDate; }
            set { SetProperty(ref _publishDate, value); }
        }

        private int _rowspan;
        public int RowSpan
        {
            get
            {
                return 1;
            }
            set { this.SetProperty(ref this._rowspan, value); }
        }

        private int _colspan;
        public int ColSpan
        {
            get
            {
                var age = (DateTime.Now - PublishDate);
                switch ((int)age.TotalDays)
                {
                    case 0:
                    case 1:
                        return 2;
                    default:
                        return 1;
                }
            }
            set { this.SetProperty(ref this._colspan, value); }
        }

    }
}
